<?php

require_once 'configBD.php';

session_start();
if (!isset($_SESSION['login'])) {
    header("Location: index.html");
} else {
    if ($_SESSION['funcao'] == "tecnico") {
        header("Location: mainportal_cadastro.php");
    }
}

if (( $_GET['curso'] == '') || ($_GET['turma'] == '') || ($_GET['disciplina'] == '')) {
    echo "<script>alert('Digite todos os campos!');</script>";
} else {
    $aluno = $_SESSION['login'];
    $curso = $_GET['curso'];
    $turma = $_GET['turma'];
    $disciplina = $_GET['disciplina'];

    $alunoturma = $aluno . $turma;

    $query = "INSERT INTO requisicao(matricula_aluno, codigo_turma, alunoturma, data)
                    VALUES ('$aluno', '$turma', '$alunoturma', CURDATE());";

    mysql_query($query)
            or header("Location: ajuste.php?curso=&disciplina=&turma=");

    mysql_close($conexao);
}
header("Location: ajuste.php?curso=&disciplina=&turma=");
?>